'use strict';

var p1 = new Promise(function (resolve, reject) {
    setTimeout(resolve, 500, 'P1');
});
var p2 = new Promise(function (resolve, reject) {
    setTimeout(resolve, 600, 'P2');
});

//只获得先返回的结果
Promise.race([p1, p2]).then(function (result) {
    console.log(result); // 'P1'
});